#include<bits/stdc++.h>
using namespace std;
const int N=10001;
int T,n,a[N],ans,maxn,num[N];
int main(){
   freopen("color.in","r",stdin);
   freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        ans=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
            num[a[i]]++;
        }
        for(int i=1;i<=2000;i++){
            if(num[i]>=2){
                ans+=i;
            }
        }
        memset(a,0,sizeof(a));
        memset(num,0,sizeof(num));
        printf("%d\n",ans);
    }

    return 0;
}
